package com.cu.simpleerp.frame.session;

import com.cu.simpleerp.system.model.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author jintian
 * @date 2018/11/1 11:06
 */
public class SessionManagerUtil {

    private static SessionManager sessionManager;

    /**
     * 刷新session
     *
     * @param request
     */
    public static void refashSession(HttpServletRequest request) {
        sessionManager.refashSession(request);
    }

    ;

    /**
     * 去除session
     *
     * @param request
     */
    public static void removeSession(HttpServletRequest request) {
        sessionManager.removeSession(request);
    }

    ;

    /**
     * 添加session
     *
     * @param response
     */
    public static void addSession(HttpServletResponse response, HttpServletRequest request, String value) {
        sessionManager.addSession(response, request, value);
    }

    ;

    /**
     * 检查session是否存在
     *
     * @return
     */
    public static boolean checkSession(HttpServletRequest request) {
        return sessionManager.checkSession(request);
    }

    ;

    public static SessionManager getSessionManager() {
        return sessionManager;
    }

    public static void setSessionManager(SessionManager sessionManager) {
        SessionManagerUtil.sessionManager = sessionManager;
    }

    /**
     * 获取登录用户
     *
     * @param request
     * @return
     */
    public static User getLoginUser(HttpServletRequest request) {
        return sessionManager.getLoginUser(request);
    }
}
